public class Student implements Comparable<Student> { // create a class named students to store students' name and
														// grade
	public String name;
	public int grade;

	public Student(String n, int g) { // initiate
		this.name = n;
		this.grade = g;
	}

	@Override
	public String toString() { // get a string of name and grade;
		return this.name + ", \t\tgrade:" + this.grade;
	}

	@Override
	public boolean equals(Object obj) { // Override equals
		if (this == obj) {
			return true;
		}
		if (obj instanceof Student) {
			Student other = (Student) obj;

			if (this.name.equals(other.name) && this.grade == other.grade) {
				return true;
			}
		}
		return false;
	}

	@Override
	public int compareTo(Student b) { // 1st std is grade, 2nd is name (lexicographical order)
		if (this.grade > b.grade) {
			return -1;
		}
		if (this.grade == b.grade && this.name.compareTo(b.name) < 0) {
			return -1;
		}
		if (this.grade == b.grade && this.name.equals(b.name)) {
			return 0;
		}
		return 1;
	}
}